﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Chapter22
{
    using Chapter22.View;
    using Chapter22.ViewModel;

    /// <summary>
    /// 第22章 列表、树和网络
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            #region 01 ListView 控件
            /*
             * 01 使用 GridView 创建列
             * 02 合建自定义视图
             * */
            #endregion

            #region 02 TreeView 控件
            /*
             * 01 创建数据绑定的 TreeView 控件
             * 02 将 DataSet 对象绑定到 TreeView 控件
             * 03 即时创建节点
             * */
            #endregion

            #region 03 DataGrid 控件
            /*
             * 01 改变列的尺寸与重新安排列
             * 02 定义列
             * 03 设置列的格式和样式
             * 04 设置行的格式
             * 05 显示行细节
             * 06 冻结列
             * 07 选择
             * 08 排序
             * 09 编辑
             * */
            #endregion

            #region 04 小结
            #endregion
        }

        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Command == ApplicationCommands.Open)
            {
                var button = e.Source as Button;
                if (button == button1)
                {
                    Demo(new BasicListView());
                }
                if (button == button2)
                {
                    Demo(new ListView());
                }
                if (button == button3)
                {
                    Demo(new BoundTreeView());
                }
                if (button == button4)
                {
                    Demo(new DirectoryTreeView());
                }
                if (button == button5)
                {
                    Demo(new DataGridTest());
                }
                if (button == button6)
                {
                    Demo(new DataGridDetails());
                }
            }
        }

        private void Demo(Window window)
        {
            window.Owner = this;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.ShowDialog();
        }
    }
}
